package com.bbzn.device.client.controller;

import com.bbzn.device.client.aspect.OperationAnnotation;
import com.bbzn.device.client.dto.index.IndexBuildingDTO;
import com.bbzn.device.client.service.CommonService;
import com.bbzn.device.client.service.ProductService;
import com.bbzn.device.client.utils.BaseApiService;
import com.bbzn.device.client.utils.BaseResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author wulongbo
 * @Date 2022/1/13 16:12
 * @Version 1.0
 */

@RestController
@RequestMapping("/worksite")
@Slf4j
public class WorkSiteIndexController extends BaseApiService {

    @Autowired
    private CommonService commonService;


    @Autowired
    private ProductService productService;

    /**
     * 返回主页数据
     *
     * @param request
     * @return
     * @throws Exception
     */
    @RequestMapping(value = "/getWorkSiteIndex", method = RequestMethod.POST)
    @OperationAnnotation(content = "获取工地首页")
    public BaseResponse getWorkSiteIndex(HttpServletRequest request) throws Exception {
        Long userId = commonService.getUserId(request);
        IndexBuildingDTO indexBuildingDTO = productService.getBuildIndex(userId);
        return setResultSuccess(indexBuildingDTO);
    }

}
